<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>智能社——http://www.zhinengshe.com</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <style>

    </style>
    <script src="vue.js"></script>
    <script>
        window.onload=function(){
            new Vue({
                el:'#box',
                data:{
					b: '我是父组件变量',
                    giveData:{
                        a:'我是父组件对象'
                    }
                },
                components:{
                    'child-obj':{
                        props:['msg'],
                        template:'#child',
                        methods:{
                            change1(){
                                this.msg.a='对象被改了';
                            }
                        }
                    },
					'child-var':{
						props:['msg'],
						template:'#child1',
						methods:{
							change2(){
								this.msg='变量被改了';
							}
						}
					}
                }
            });
        };
    </script>
</head>
<body>
    <template id="child">
        <div>
            <span>我是子组件对象</span>
            <input type="button" value="改变对象" @click="change1">
            <strong>{{msg.a}}</strong>

        </div>
    </template>
	
	<template id="child1">
	    <div>
	        <span>我是子组件变量</span>
			<input type="button" value="改变变量" @click="change2">
			<strong>{{msg}}</strong>
	    </div>
	</template>

    <div id="box">
        父级对象: ->{{giveData.a}}========父级变量: ->{{b}}
        <br>
        <child-obj :msg="giveData"></child-obj>
		<child-var :msg="b"></child-var>
    </div>
</body>
</html>



















